using System.Collections.Generic;
using System.Resources;
using System.Reflection;

namespace ClassBuilderWizard.Interfaces
{
    /// <summary>
    /// The object returned by a class implementing the IManualPlugin interface.
    /// </summary>
    public class ManualObject
    {
        private List<ManualProperty> _Properties;
        private string _EntityFieldTemplate;
        private string _EntityPropertyTemplate;
        private string _EntityInitTemplate;
        private string _EntityTemplate;
        private string _EntityPropertyArrayComparer;
        private string _EntityPropertyNonArrayComparer;

        /// <summary>
        /// Create a new instance of ManualObject
        /// </summary>
        /// <param name="language">The ProjectType (programming language) of the Visual Studio project</param>
        public ManualObject(ProjectType language)
        {
            this._Properties = new List<ManualProperty>();

            ResourceManager rm = null;
            Assembly asm = Assembly.GetExecutingAssembly();
            switch (language)
            {
                case ProjectType.CSharp:
                    rm = new ResourceManager("ClassBuilderWizard.Interfaces.Templates_CS", asm);
                    break;
                case ProjectType.VB:
                    rm = new ResourceManager("ClassBuilderWizard.Interfaces.Templates_VB", asm);
                    break;
            }

            this._EntityTemplate = rm.GetString("Entity");
            this._EntityFieldTemplate = rm.GetString("Entity_Field_Template");
            this._EntityInitTemplate = rm.GetString("Entity_Init_Template");
            this._EntityPropertyTemplate = rm.GetString("Entity_Property_Template");
            this._EntityPropertyArrayComparer = rm.GetString("Entity_Property_Array_Comparer");
            this._EntityPropertyNonArrayComparer = rm.GetString("Entity_Property_NonArray_Comparer");
        }
        /// <summary>
        /// Create a new instance of ManualObject. The language used defaults to CSharp.
        /// </summary>
        public ManualObject() : this(ProjectType.CSharp)
        {
        }

        /// <summary>
        /// The properties (types and names) of the manual object
        /// </summary>
        public List<ManualProperty> Properties
        {
            get { return _Properties; }
            set { _Properties = value; }
        }
        /// <summary>
        /// The template that will be used to generate a field (private member) of the entity class
        /// </summary>
        /// <remarks>
        /// The macros used in this template are:
        /// [[Type]] - The CLR type of the field
        /// [[Name]] - The name of the field
        /// </remarks>
        //[Browsable(false)]
        //public string EntityFieldTemplate
        //{
        //    get { return _EntityFieldTemplate; }
        //    set { _EntityFieldTemplate = value; }
        //}
        /// <summary>
        /// The template that will be used to generate a public property on the entity class
        /// </summary>
        /// <remarks>
        /// The macros used in this template are:
        /// [[Type]] - The CLR type of the property
        /// [[Name]] - The name of the property
        /// </remarks>
        //[Browsable(false)]
        //public string EntityPropertyTemplate
        //{
        //    get { return _EntityPropertyTemplate; }
        //    set { _EntityPropertyTemplate = value; }
        //}
        /// <summary>
        /// The template that will be used to generate an line of code to initialize a field
        /// </summary>
        /// <remarks>
        /// The macros used in this template are:
        /// [[Name]] - The name of the field
        /// [[Default]] - The default value to assign to the field
        /// </remarks>
        //[Browsable(false)]
        //public string EntityInitTemplate
        //{
        //    get { return _EntityInitTemplate; }
        //    set { _EntityInitTemplate = value; }
        //}
        /// <summary>
        /// The template that will be used to generate the entity object
        /// </summary>
        /// <remarks>
        /// Several macros are used to indicate the placement of certain pieces of the entity class:
        /// [!output SAFE_NAMESPACE_NAME] - The namespace of the project
        /// [!output SAFE_CLASS_NAME] - The name of the class
        /// [!output PRIVATE_DEFINITIONS] - The definition of private fields
        /// [!output INITIALIZE_DEFINITIONS] - The initialization of private fields
        /// [!output PUBLIC_DEFINITIONS] - The definition of public properties
        /// </remarks>
        //[Browsable(false)]
        //public string EntityTemplate
        //{
        //    get { return _EntityTemplate; }
        //    set { _EntityTemplate = value; }
        //}
        /// <summary>
        /// The comparison operator for array types
        /// </summary>
        //[Browsable(false)]
        //public string EntityPropertyArrayComparer
        //{
        //    get { return _EntityPropertyArrayComparer; }
        //    set { _EntityPropertyArrayComparer = value; }
        //}
        /// <summary>
        /// The comparison operator for non-array types
        /// </summary>
        //[Browsable(false)]
        //public string EntityPropertyNonArrayComparer
        //{
        //    get { return _EntityPropertyNonArrayComparer; }
        //    set { _EntityPropertyNonArrayComparer = value; }
        //}
    }
}
